package de.p5.test;

import wiiusej.WiiUseApiManager;
import wiiusej.Wiimote;
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;

public class MyClass implements WiimoteListener{

	private int number;
	
	public MyClass(int num){
		number = num;
	}
	
    public void onButtonsEvent(WiimoteButtonsEvent arg0) {
        if (arg0.getButtonsJustReleased()>0){
        	System.out.println("!- " + number + " -!");
        	System.out.println(arg0);
        }
    }

    public void onIrEvent(IREvent arg0) {
    	System.out.println("!- " + number + " -!");
        System.out.println(arg0);
    }

    public void onMotionSensingEvent(MotionSensingEvent arg0) {
        //System.out.println(arg0 + "yay");
    }

    public void onExpansionEvent(ExpansionEvent arg0) {
        System.out.println(arg0 + "yay");
    }

    public void onStatusEvent(StatusEvent arg0) {
        //System.out.println(arg0 + "yay");
    }

    public void onDisconnectionEvent(DisconnectionEvent arg0) {
        System.out.println(arg0 + "yay");
    }

    public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
        //System.out.println(arg0 + "yay");
    }

    public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
        //System.out.println(arg0 + "yay");
    }

    public static void main(String[] args) {
        Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(2, true);
        Wiimote wiimote = wiimotes[0];
        Wiimote wii2 = wiimotes[1];
        wiimote.activateIRTRacking();
        wii2.activateIRTRacking();
        //wiimote.activateMotionSensing();
        wiimote.addWiiMoteEventListeners(new MyClass(1));
        wii2.addWiiMoteEventListeners(new MyClass(2));
        System.out.println("Initialized");
        System.out.println(wiimote.getWiiMoteEventListeners());
        wiimote.setLeds(true, false, false, true);
        wii2.setLeds(false, true, true, false);
        //wiimote.setIrSensitivity(5);
    }

	@Override
	public void onClassicControllerInsertedEvent(
			ClassicControllerInsertedEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e) {
		// TODO Auto-generated method stub
		
	}
}
